$(function(){
    /* 变量定义 */
    var overview = {
        main: $('#overview'),  // 总览容器元素
        data: {},
        initVariable: function () { // 变量合集
            var _this = this;
            this.month = this.main.find('.month');

            this.chartDevice = this.main.find('#chart-device');   // 新增保内设备图表
            this.chartFault = this.main.find('#chart-fault');  // 故障次数图表
            this.chartUpkeep = this.main.find('#chart-upkeep');   // 保养图表

            this.chartYear = this.main.find('#chart-year');    // 年份图表
            this.chartMonth = this.main.find('.month-chart');   // 月份图表
            this.chartCompletion = this.main.find('#chart-completion'); // 完成率图表
            /* echarts option */
            this.optionDevice = {
                grid: {
                    top: '10px',
                    bottom: '0',
                    left: '3%',
                    right: '40%',
                    containLabel: true
                },
                tooltip: {
                    trigger: 'axis',
                    axisPointer: { // 坐标轴指示器，坐标轴触N发有效
                        type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
                    },
                    position: function(point){
                        return [point[0] + 5, point[1] + 5];
                    },
                    formatter: function (a) {
                        if (_this.data.insideOutsideDeviceCountList[0].type === 1) {
                            return '保外设备：' + _this.data.insideOutsideDeviceCountList[1].counts + '台</br>' +
                                '保内设备：' + _this.data.insideOutsideDeviceCountList[0].counts + '台';
                        } else {
                            return '保外设备：' + _this.data.insideOutsideDeviceCountList[0].counts + '台</br>' +
                                '保内设备：' + _this.data.insideOutsideDeviceCountList[1].counts + '台';
                        }
                    }
                },
                xAxis:  {
                    show: false,
                    type: 'value'
                },
                yAxis: {
                    type: 'category',
                    axisTick : {show: false},
                    nameTextStyle: {
                        color: '#fff'
                    },
                    axisLine: {
                        show: true,
                        lineStyle:{
                            color:'#fff'
                        }
                    },
                    inverse: true,
                    data: ['保外', '保内']
                },
                series: [{
                    type: 'bar',
                    stack: 'curIncome',
                    itemStyle:{
                        normal: {
                            color: '#62dcdd',
                            barBorderRadius:[0, 200, 200 ,0]
                        }
                    },
                    label: {
                        normal: {
                            show: true,
                            position: "right",
                            textStyle: {
                                color: '#fff'
                            },
                            formatter: function(a) {
                                if (_this.data.insideOutsideDeviceCountList) {
                                    if (a.dataIndex === 0) {
                                        if (_this.data.insideOutsideDeviceCountList[0].type === 1) {
                                            return _this.data.insideOutsideDeviceCountList[1].counts + '台';
                                        } else {
                                            return _this.data.insideOutsideDeviceCountList[0].counts + '台';
                                        }
                                    } else {
                                        if (_this.data.insideOutsideDeviceCountList[0].type === 1) {
                                            return _this.data.insideOutsideDeviceCountList[0].counts + '台';
                                        } else {
                                            return _this.data.insideOutsideDeviceCountList[1].counts + '台';
                                        }
                                    }
                                }
                            }
                        }
                    },
                    barGap: '-100%',
                    barWidth:'30%',
                    data: [0,10]
                }]
            };
            this.optionFault = {
                tooltip: {
                    trigger: 'item',
                    formatter: "{b} : {c} 次"
                },
                series: [{
                    type: 'pie',
                    hoverAnimation: false,
                    hoverOffset: 0,
                    startAngle: 180,
                    radius: ['70%', '90%'],
                    label: {
                        normal: {
                            formatter: '故障率\n\n0%',
                            position: 'center',
                            textStyle: {
                                color: '#fff',
                                fontSize: 14
                            }
                        }
                    },
                    data: [{
                        value: 100,
                        name: '设备数量',
                        itemStyle: {
                            normal: {
                                color: 'transparent'
                            }
                        }
                    }]
                },{
                    type: 'pie',
                    hoverAnimation: false,
                    hoverOffset: 0,
                    startAngle: 180,
                    radius: ['70%', '90%'],
                    label: {
                        normal: {
                            show: false
                        }
                    },
                    data: [{
                        value: 70,
                        name: '故障次数',
                        itemStyle: {
                            normal: {
                                color: '#2cfdaa'
                            }
                        }
                    }, {
                        value: 30,
                        name: '设备数量',
                        itemStyle: {
                            normal: {
                                color: '#62dcdd'
                            }
                        }
                    }]
                }]
            };
            this.optionUpkeep = {
                tooltip: {
                    trigger: 'item',
                    formatter: "保养次数：\n\n0次"
                },
                series: [{
                    type: 'pie',
                    hoverAnimation: false,
                    hoverOffset: 0,
                    startAngle: 180,
                    radius: ['70%', '90%'],
                    label: {
                        normal: {
                            formatter: '+',
                            position: 'center',
                            textStyle: {
                                color: '#fff',
                                fontSize: 14
                            }
                        }
                    },
                    data: [{
                        value: 70,
                        name: '平均故障时间',
                        itemStyle: {
                            normal: {
                                color: '#62dcdd'
                            }
                        }
                    }]
                }]
            };

            this.optionYear = {
                backgroundColor: 'transparent',
                color: ['#00a559', '#ff841a', '#00c0ef', '#f09d0f'],
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    bottom: '3%',
                    left: "50%",
                    data: ['A | 安装完成率', 'B | 保养完成率', 'C | 维修完成率'],
                    textStyle: {
                        color: '#fff'
                    },
                    itemGap: 5,
                    itemWidth: 0,
                    selectedMode: true,
                    orient: "vertical"
                },
                series: [{
                    name: 'A | 安装完成率',
                    type: 'pie',
                    startAngle: 270,
                    minAngle: 10,
                    clockWise: true, //顺时加载
                    hoverAnimation: false, //鼠标移入变大
                    center: ['50%', '50%'],
                    radius: ['60%', '70%'],
                    data: [{
                        value: 1,
                        itemStyle: {
                            normal: {
                                color: '#00a559'
                            }
                        },
                        label: {
                            normal: {
                                show: false,
                                position: 'center'
                            }
                        }
                    }, {
                        value: 0.33,
                        silent: true,
                        itemStyle: {
                            normal: {
                                color: 'transparent'
                            }
                        },
                        label: {
                            normal: {
                                show: false,
                                position: 'center'
                            }
                        }
                    }]
                }, {
                    name: 'B | 保养完成率',
                    type: 'pie',
                    startAngle: 270,
                    minAngle: 10,
                    clockWise: true, //顺时加载
                    hoverAnimation: false, //鼠标移入变大
                    center: ['50%', '50%'],
                    radius: ['70%', '80%'],
                    data: [{
                        value: 1,
                        itemStyle: {
                            normal: {
                                color: '#ff841a'
                            }
                        },
                        label: {
                            normal: {
                                show: false,
                                position: 'center'
                            }
                        }
                    }, {
                        value: 0.33,
                        silent: true,
                        itemStyle: {
                            normal: {
                                color: 'transparent'
                            }
                        },
                        label: {
                            normal: {
                                show: false,
                                position: 'center'
                            }
                        }
                    }]
                }, {
                    name: 'C | 维修完成率',
                    type: 'pie',
                    startAngle: 270,
                    minAngle: 10,
                    clockWise: true, //顺时加载
                    hoverAnimation: false, //鼠标移入变大
                    center: ['50%', '50%'],
                    radius: ['80%', '90%'],
                    data: [{
                        value: 1,
                        itemStyle: {
                            normal: {
                                color: '#00c0ef'
                            }
                        },
                        label: {
                            normal: {
                                show: false,
                                position: 'center'
                            }
                        }
                    }, {
                        value: 0.33,
                        silent: true,
                        itemStyle: {
                            normal: {
                                color: 'transparent'
                            }
                        },
                        label: {
                            normal: {
                                show: false,
                                position: 'center'
                            }
                        }
                    }]
                }]
            };
            this.optionMonth = {
                backgroundColor: 'transparent',
                series: [{
                    type: 'pie',
                    radius: [0, '100%'],
                    legendHoverLink: false,
                    hoverAnimation: false,
                    silent: true,
                    itemStyle: {
                        normal: {
                            color: '#888890'
                        },
                        emphasis: {
                            color: '#888890'
                        }
                    },
                    tooltip: {
                        show: false
                    },
                    label: {normal:{show:false}},
                    data: [100]
                }, {
                    type: 'pie',
                    radius: ['78%', '81%'],
                    legendHoverLink: false,
                    hoverAnimation: false,
                    itemStyle: {
                        normal: {
                            color: '#fff'
                        },
                        emphasis: {
                            color: '#fff'
                        }
                    },
                    tooltip: {
                        show: false
                    },
                    label: {normal:{show:false}},
                    data: [100]
                }, {
                    type: 'pie',
                    radius: [0, '90%'],
                    tooltip: {
                        show: false
                    },
                    label: {normal:{show:false}},
                    data: [{
                        value: 85,
                        legendHoverLink: false,
                        hoverAnimation: false,
                        itemStyle: {
                            normal: {
                                color: '#fff'
                            },
                            emphasis: {
                                color: '#fff'
                            }
                        }
                    }, {
                        value: 15,
                        legendHoverLink: false,
                        hoverAnimation: false,
                        itemStyle: {
                            normal: {
                                color: 'transparent'
                            }
                        }
                    }]
                }]
            };

            var optionOpenColor = {
                arr: ['#62dcdd', '#2cfdaa', '#84fba1', '#c9f96f', '#f7fc57', '#9297fb', '#4cb8f9'],
                index: 0,
                index2: 6,
                getColor: function (){
                    return this.arr[this.index++];
                },
                getColor2: function (){
                    return this.arr[this.index2++ % this.arr.length];
                }
            };
            this.optionCompletion = {
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow'
                    },
                    formatter: function (param) {
                        return param[0].name + ':' + fix2(param[0].value) + '%';
                    }
                },
                grid: {
                    top: '3%',
                    left: '0%',
                    right: '0%',
                    bottom: '3%',
                    containLabel: true
                },
                yAxis: [{
                    type: 'category',
                    data: ['衢州市', '金华市', '绍兴市', '湖州市', '嘉兴市', '温州市', '宁波市'],
                    inverse: true,
                    axisLine: {
                        lineStyle: {
                            color: '#fff'
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    axisLabel: {
                        color: '#fff'
                    }
                }],
                xAxis: [{
                    type: 'value',
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: false
                    },
                    axisLabel: {
                        show: false
                    },
                    splitLine: {
                        show: false
                    }
                }],
                series: [{
                    type: 'bar',
                    barWidth: '50%',
                    barGap: '-100%',
                    itemStyle: {
                        normal: {
                            barBorderRadius: [0, 20, 20, 0]
                        }
                    },
                    z: 11,
                    data: [{
                        value: 0,
                        name: -100,
                        itemStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                                    offset: 0,
                                    color: optionOpenColor.getColor()
                                }, {
                                    offset: 1,
                                    color: optionOpenColor.getColor2()
                                }], false)
                            }
                        }
                    }, {
                        value: 0,
                        name: 2016101411,
                        itemStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                                    offset: 0,
                                    color: optionOpenColor.getColor()
                                }, {
                                    offset: 1,
                                    color: optionOpenColor.getColor2()
                                }], false)
                            }
                        }
                    }, {
                        value: 0,
                        name: 2016101405,
                        itemStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                                    offset: 0,
                                    color: optionOpenColor.getColor()
                                }, {
                                    offset: 1,
                                    color: optionOpenColor.getColor2()
                                }], false)
                            }
                        }
                    }, {
                        value: 0,
                        name: 2016101404,
                        itemStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                                    offset: 0,
                                    color: optionOpenColor.getColor()
                                }, {
                                    offset: 1,
                                    color: optionOpenColor.getColor2()
                                }], false)
                            }
                        }
                    }, {
                        value: 0,
                        name: 2016101403,
                        itemStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                                    offset: 0,
                                    color: optionOpenColor.getColor()
                                }, {
                                    offset: 1,
                                    color: optionOpenColor.getColor2()
                                }], false)
                            }
                        }
                    }, {
                        value: 58,
                        name: 2016101403,
                        itemStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                                    offset: 0,
                                    color: optionOpenColor.getColor()
                                }, {
                                    offset: 1,
                                    color: optionOpenColor.getColor2()
                                }], false)
                            }
                        }
                    }, {
                        value: 26,
                        name: 2016101403,
                        itemStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                                    offset: 0,
                                    color: optionOpenColor.getColor()
                                }, {
                                    offset: 1,
                                    color: optionOpenColor.getColor2()
                                }], false)
                            }
                        }
                    }]
                }, {
                    type: 'bar',
                    barWidth: '50%',
                    z: 10,
                    itemStyle: {
                        normal: {
                            barBorderRadius: [0, 20, 20, 0]
                        }
                    },
                    data: [{
                        value: 100,
                        itemStyle: {
                            normal: {
                                color: '#c3c4c8'
                            }
                        }
                    }, {
                        value: 100,
                        itemStyle: {
                            normal: {
                                color: '#c3c4c8'
                            }
                        }
                    }, {
                        value: 100,
                        itemStyle: {
                            normal: {
                                color: '#c3c4c8'
                            }
                        }
                    }, {
                        value: 100,
                        itemStyle: {
                            normal: {
                                color: '#c3c4c8'
                            }
                        }
                    }, {
                        value: 100,
                        itemStyle: {
                            normal: {
                                color: '#c3c4c8'
                            }
                        }
                    }, {
                        value: 100,
                        itemStyle: {
                            normal: {
                                color: '#c3c4c8'
                            }
                        }
                    }, {
                        value: 100,
                        itemStyle: {
                            normal: {
                                color: '#c3c4c8'
                            }
                        }
                    }]
                }]
            };
        },
        1501: {status: false, data: []},
        1502: {status: false, data: []},
        1503: {status: false, data: [{
                "id":"1481185324567002",
                "name":"便携式多参数监护仪",
                "sn":null,
                "assetsNo":null,
                "hospital": '浙江大学医学院附属第一医院',
                "department":"急诊科",
                "firstTypeName":"电子仪器",
                "modalName":"IMEC-10",
                "manufacturer":null,
                "price":2170000,
                "depreciationPrice":null,
                "enableDate":null,
                "usedTime":null,
                "ageLimitMeasure":3.230136986301,
                "scrapTime":null,
                "repairTime":null,
                "repairStatus":null,
                "deviceStatus":null,
                "haltMin":null,
                "faultDescription":null,
                "serviceProvider":null,
                "responsible":"",
                "warn":"G",
                "haveFaultMin":null,
                "lastCompulsoryDate":null,
                "planCompulsoryDate":"2017-06-29",
                "lastUpkeepDate":null,
                "planUpkeepDate":null,
                "lastInspectionDate":null,
                "planInspectionDate":null
            }, {
                "id":"1481185324568002",
                "name":"便携式多参数监护仪",
                "sn":null,
                "assetsNo":null,
                "hospital":'杭州市萧山区中医院',
                "department":"急诊科",
                "firstTypeName":"电子仪器",
                "modalName":"IMEC-10",
                "manufacturer":null,
                "price":2170000,
                "depreciationPrice":null,
                "enableDate":null,
                "usedTime":null,
                "ageLimitMeasure":3.230136986301,
                "scrapTime":null,
                "repairTime":null,
                "repairStatus":null,
                "deviceStatus":null,
                "haltMin":null,
                "faultDescription":null,
                "serviceProvider":null,
                "responsible":"",
                "warn":"Y",
                "haveFaultMin":null,
                "lastCompulsoryDate":null,
                "planCompulsoryDate":"2017-06-29",
                "lastUpkeepDate":null,
                "planUpkeepDate":null,
                "lastInspectionDate":null,
                "planInspectionDate":null
            }, {
                "id":"1481185324569002",
                "name":"便携式多参数监护仪",
                "sn":null,
                "assetsNo":null,
                "hospital":'杭州市萧山区中医院',
                "department":"急诊科",
                "firstTypeName":"电子仪器",
                "modalName":"IMEC-10",
                "manufacturer":null,
                "price":2170000,
                "depreciationPrice":null,
                "enableDate":null,
                "usedTime":null,
                "ageLimitMeasure":3.230136986301,
                "scrapTime":null,
                "repairTime":null,
                "repairStatus":null,
                "deviceStatus":null,
                "haltMin":null,
                "faultDescription":null,
                "serviceProvider":null,
                "responsible":"",
                "warn":"Y",
                "haveFaultMin":null,
                "lastCompulsoryDate":null,
                "planCompulsoryDate":"2017-06-29",
                "lastUpkeepDate":null,
                "planUpkeepDate":null,
                "lastInspectionDate":null,
                "planInspectionDate":null
            }, {
                "id":"1481185324570002",
                "name":"便携式多参数监护仪",
                "sn":null,
                "assetsNo":null,
                "hospital":'浙江国家电网公司职业病防治院',
                "department":"急诊科",
                "firstTypeName":"电子仪器",
                "modalName":"IMEC-10",
                "manufacturer":null,
                "price":2170000,
                "depreciationPrice":null,
                "enableDate":null,
                "usedTime":null,
                "ageLimitMeasure":3.230136986301,
                "scrapTime":null,
                "repairTime":null,
                "repairStatus":null,
                "deviceStatus":null,
                "haltMin":null,
                "faultDescription":null,
                "serviceProvider":null,
                "responsible":"",
                "warn":"G",
                "haveFaultMin":null,
                "lastCompulsoryDate":null,
                "planCompulsoryDate":"2017-06-29",
                "lastUpkeepDate":null,
                "planUpkeepDate":null,
                "lastInspectionDate":null,
                "planInspectionDate":null
            }]},
        1504: {status: false, data: [{
                "id":"1481185324892002",
                "name":"16排多层螺旋CT机",
                "sn":null,
                "assetsNo":null,
                "hospital":'浙江国家电网公司职业病防治院',
                "department":"放射科",
                "firstTypeName":"大型影像",
                "modalName":"Lightspeed 16",
                "manufacturer":null,
                "price":552610275,
                "depreciationPrice":null,
                "enableDate":null,
                "usedTime":null,
                "ageLimitMeasure":2.386849315068,
                "scrapTime":null,
                "repairTime":"2018-02-06 13:56",
                "repairStatus":"3003",
                "deviceStatus":"宕机",
                "haltMin":36313,
                "faultDescription":"",
                "serviceProvider":"上海拓美信息科技有限公司",
                "responsible":"tm_003",
                "warn":"R",
                "haveFaultMin":36313,
                "lastCompulsoryDate":null,
                "planCompulsoryDate":null,
                "lastUpkeepDate":null,
                "planUpkeepDate":null,
                "lastInspectionDate":null,
                "planInspectionDate":null
            }, {
                    "id":"1481185324922002",
                    "name":"数字化乳腺Ｘ射线机",
                    "sn":null,
                    "assetsNo":null,
                    "hospital":'杭州市萧山区中医院',
                    "department":"放射科",
                    "firstTypeName":"普放",
                    "modalName":"MammoDiagnost DR",
                    "manufacturer":null,
                    "price":279750000,
                    "depreciationPrice":null,
                    "enableDate":null,
                    "usedTime":null,
                    "ageLimitMeasure":null,
                    "scrapTime":null,
                    "repairTime":"2018-01-03 08:48",
                    "repairStatus":"3003",
                    "deviceStatus":"宕机",
                    "haltMin":85581,
                    "faultDescription":"",
                    "serviceProvider":"飞利浦(荷兰）",
                    "responsible":"gcs",
                    "warn":"G",
                    "haveFaultMin":85581,
                    "lastCompulsoryDate":null,
                    "planCompulsoryDate":null,
                    "lastUpkeepDate":null,
                    "planUpkeepDate":null,
                    "lastInspectionDate":null,
                    "planInspectionDate":null
                }]},
        1505: {status: false, data: [{
                "id":"1506501120088002",
                "name":"治疗车（大）",
                "sn":null,
                "assetsNo":null,
                "hospital":'浙江大学医学院附属第一医院',
                "department":"科教科",
                "firstTypeName":null,
                "modalName":"10012-1",
                "manufacturer":null,
                "price":244500,
                "depreciationPrice":null,
                "enableDate":null,
                "usedTime":null,
                "ageLimitMeasure":0.190215264187,
                "scrapTime":null,
                "repairTime":null,
                "repairStatus":null,
                "deviceStatus":null,
                "haltMin":null,
                "faultDescription":null,
                "serviceProvider":null,
                "responsible":null,
                "warn":"R",
                "haveFaultMin":null,
                "lastCompulsoryDate":null,
                "planCompulsoryDate":null,
                "lastUpkeepDate":null,
                "planUpkeepDate":null,
                "lastInspectionDate":null,
                "planInspectionDate":"2018-03-01"
            }, {
                "id":"1506500311864002",
                "name":"治疗车（大）",
                "sn":null,
                "assetsNo":null,
                "hospital":'杭州市萧山区中医院',
                "department":"科教科",
                "firstTypeName":null,
                "modalName":"10012-1",
                "manufacturer":null,
                "price":244500,
                "depreciationPrice":null,
                "enableDate":null,
                "usedTime":null,
                "ageLimitMeasure":0.121643835616,
                "scrapTime":null,
                "repairTime":null,
                "repairStatus":null,
                "deviceStatus":null,
                "haltMin":null,
                "faultDescription":null,
                "serviceProvider":null,
                "responsible":null,
                "warn":"G",
                "haveFaultMin":null,
                "lastCompulsoryDate":null,
                "planCompulsoryDate":null,
                "lastUpkeepDate":null,
                "planUpkeepDate":null,
                "lastInspectionDate":null,
                "planInspectionDate":"2018-03-01"
            }, {
                "id":"1506500311865002",
                "name":"外科吊塔",
                "sn":null,
                "assetsNo":null,
                "hospital":'浙江大学医学院附属邵逸夫医院',
                "department":"科教科",
                "firstTypeName":"手术急救",
                "modalName":"Tower212",
                "manufacturer":null,
                "price":4800000,
                "depreciationPrice":null,
                "enableDate":null,
                "usedTime":null,
                "ageLimitMeasure":0.050684931506,
                "scrapTime":null,
                "repairTime":null,
                "repairStatus":null,
                "deviceStatus":null,
                "haltMin":null,
                "faultDescription":null,
                "serviceProvider":null,
                "responsible":null,
                "warn":"R",
                "haveFaultMin":null,
                "lastCompulsoryDate":null,
                "planCompulsoryDate":null,
                "lastUpkeepDate":null,
                "planUpkeepDate":null,
                "lastInspectionDate":null,
                "planInspectionDate":"2018-03-01"
            }, {
                "id":"1506501120104002",
                "name":"外科吊塔",
                "sn":null,
                "assetsNo":null,
                "hospital":'浙江大学医学院附属邵逸夫医院',
                "department":"科教科",
                "firstTypeName":"手术急救",
                "modalName":"Tower212",
                "manufacturer":null,
                "price":4800000,
                "depreciationPrice":null,
                "enableDate":null,
                "usedTime":null,
                "ageLimitMeasure":0.061872146118,
                "scrapTime":null,
                "repairTime":null,
                "repairStatus":null,
                "deviceStatus":null,
                "haltMin":null,
                "faultDescription":null,
                "serviceProvider":null,
                "responsible":null,
                "warn":"Y",
                "haveFaultMin":null,
                "lastCompulsoryDate":null,
                "planCompulsoryDate":null,
                "lastUpkeepDate":null,
                "planUpkeepDate":null,
                "lastInspectionDate":null,
                "planInspectionDate":"2018-03-01"
            }, {
                "id":"1506500311845002",
                "name":"医用电子血压计",
                "sn":null,
                "assetsNo":null,
                "hospital":'杭州市萧山区中医院',
                "department":"院部",
                "firstTypeName":"基础设施",
                "modalName":"HBP-1300",
                "manufacturer":null,
                "price":200000,
                "depreciationPrice":null,
                "enableDate":null,
                "usedTime":null,
                "ageLimitMeasure":0.140273972602,
                "scrapTime":null,
                "repairTime":null,
                "repairStatus":null,
                "deviceStatus":null,
                "haltMin":null,
                "faultDescription":null,
                "serviceProvider":null,
                "responsible":null,
                "warn":"R",
                "haveFaultMin":null,
                "lastCompulsoryDate":null,
                "planCompulsoryDate":null,
                "lastUpkeepDate":null,
                "planUpkeepDate":null,
                "lastInspectionDate":null,
                "planInspectionDate":"2018-03-01"
            }, {
                "id":"1506500311846002",
                "name":"医用电子血压计",
                "sn":null,
                "assetsNo":null,
                "hospital":'杭州市萧山区中医院',
                "department":"院部",
                "firstTypeName":"基础设施",
                "modalName":"HBP-1300",
                "manufacturer":null,
                "price":200000,
                "depreciationPrice":null,
                "enableDate":null,
                "usedTime":null,
                "ageLimitMeasure":0.140273972602,
                "scrapTime":null,
                "repairTime":null,
                "repairStatus":null,
                "deviceStatus":null,
                "haltMin":null,
                "faultDescription":null,
                "serviceProvider":null,
                "responsible":null,
                "warn":"G",
                "haveFaultMin":null,
                "lastCompulsoryDate":null,
                "planCompulsoryDate":null,
                "lastUpkeepDate":null,
                "planUpkeepDate":null,
                "lastInspectionDate":null,
                "planInspectionDate":"2018-03-01"
            }]},
        1506: {status: false, data: [{
                "id":"1481185323326002",
                "name":"超高清腹腔镜系统",
                "sn":null,
                "assetsNo":null,
                "hospital":'浙江大学医学院附属邵逸夫医院',
                "department":"外科",
                "firstTypeName":"内窥镜",
                "modalName":"IMAGE 1 SPIES",
                "manufacturer":null,
                "price":158000000,
                "depreciationPrice":null,
                "enableDate":null,
                "usedTime":null,
                "ageLimitMeasure":2.024657534246,
                "scrapTime":null,
                "repairTime":null,
                "repairStatus":null,
                "deviceStatus":null,
                "haltMin":null,
                "faultDescription":null,
                "serviceProvider":null,
                "responsible":null,
                "warn":"G",
                "haveFaultMin":null,
                "lastCompulsoryDate":null,
                "planCompulsoryDate":null,
                "lastUpkeepDate":null,
                "planUpkeepDate":"2018-03-26",
                "lastInspectionDate":null,
                "planInspectionDate":null
            }, {
                    "id":"1481185324918002",
                    "name":"磁共振成像系统",
                    "sn":null,
                    "assetsNo":null,
                    "hospital":'浙江大学医学院附属邵逸夫医院',
                    "department":"放射科",
                    "firstTypeName":"大型影像",
                    "modalName":"Signa HDe 1.5T",
                    "manufacturer":null,
                    "price":1256242472,
                    "depreciationPrice":null,
                    "enableDate":null,
                    "usedTime":null,
                    "ageLimitMeasure":8.843835616438,
                    "scrapTime":null,
                    "repairTime":null,
                    "repairStatus":null,
                    "deviceStatus":null,
                    "haltMin":null,
                    "faultDescription":null,
                    "serviceProvider":"上海拓美信息科技有限公司",
                    "responsible":"tm_003[tm_003]",
                    "warn":"G",
                    "haveFaultMin":null,
                    "lastCompulsoryDate":null,
                    "planCompulsoryDate":null,
                    "lastUpkeepDate":null,
                    "planUpkeepDate":"2018-03-01",
                    "lastInspectionDate":null,
                    "planInspectionDate":null
                }, {
                    "id":"1481185323326002",
                    "name":"超高清腹腔镜系统",
                    "sn":null,
                    "assetsNo":null,
                    "hospital":'杭州市萧山区中医院',
                    "department":"外科",
                    "firstTypeName":"内窥镜",
                    "modalName":"IMAGE 1 SPIES",
                    "manufacturer":null,
                    "price":158000000,
                    "depreciationPrice":null,
                    "enableDate":null,
                    "usedTime":null,
                    "ageLimitMeasure":2.024657534246,
                    "scrapTime":null,
                    "repairTime":null,
                    "repairStatus":null,
                    "deviceStatus":null,
                    "haltMin":null,
                    "faultDescription":null,
                    "serviceProvider":null,
                    "responsible":null,
                    "warn":"G",
                    "haveFaultMin":null,
                    "lastCompulsoryDate":null,
                    "planCompulsoryDate":null,
                    "lastUpkeepDate":null,
                    "planUpkeepDate":"2018-02-26",
                    "lastInspectionDate":null,
                    "planInspectionDate":null
                }, {
                    "id":"1481185324892002",
                    "name":"16排多层螺旋CT机",
                    "sn":null,
                    "assetsNo":null,
                    "hospital":'浙江大学医学院附属邵逸夫医院',
                    "department":"放射科",
                    "firstTypeName":"大型影像",
                    "modalName":"Lightspeed 16",
                    "manufacturer":null,
                    "price":552610275,
                    "depreciationPrice":null,
                    "enableDate":null,
                    "usedTime":null,
                    "ageLimitMeasure":2.386849315068,
                    "scrapTime":null,
                    "repairTime":null,
                    "repairStatus":null,
                    "deviceStatus":null,
                    "haltMin":null,
                    "faultDescription":null,
                    "serviceProvider":null,
                    "responsible":null,
                    "warn":"R",
                    "haveFaultMin":null,
                    "lastCompulsoryDate":null,
                    "planCompulsoryDate":null,
                    "lastUpkeepDate":"2017-11-12 00:00",
                    "planUpkeepDate":"2018-02-08",
                    "lastInspectionDate":null,
                    "planInspectionDate":null
                }, {
                    "id":"1481185323226002",
                    "name":"24/48小时动态血压记录仪",
                    "sn":null,
                    "assetsNo":null,
                    "hospital":'浙江国家电网公司职业病防治院',
                    "department":"心电图",
                    "firstTypeName":"电子仪器",
                    "modalName":"BR-102 plus",
                    "manufacturer":null,
                    "price":2480000,
                    "depreciationPrice":null,
                    "enableDate":null,
                    "usedTime":null,
                    "ageLimitMeasure":0.893933463796,
                    "scrapTime":null,
                    "repairTime":null,
                    "repairStatus":null,
                    "deviceStatus":null,
                    "haltMin":null,
                    "faultDescription":null,
                    "serviceProvider":null,
                    "responsible":null,
                    "warn":"Y",
                    "haveFaultMin":null,
                    "lastCompulsoryDate":null,
                    "planCompulsoryDate":null,
                    "lastUpkeepDate":null,
                    "planUpkeepDate":"2018-02-08",
                    "lastInspectionDate":null,
                    "planInspectionDate":null
                }, {
                    "id":"1481185323326002",
                    "name":"超高清腹腔镜系统",
                    "sn":null,
                    "assetsNo":null,
                    "hospital":'浙江大学医学院附属邵逸夫医院',
                    "department":"外科",
                    "firstTypeName":"内窥镜",
                    "modalName":"IMAGE 1 SPIES",
                    "manufacturer":null,
                    "price":158000000,
                    "depreciationPrice":null,
                    "enableDate":null,
                    "usedTime":null,
                    "ageLimitMeasure":2.024657534246,
                    "scrapTime":null,
                    "repairTime":null,
                    "repairStatus":null,
                    "deviceStatus":null,
                    "haltMin":null,
                    "faultDescription":null,
                    "serviceProvider":null,
                    "responsible":null,
                    "warn":"R",
                    "haveFaultMin":null,
                    "lastCompulsoryDate":null,
                    "planCompulsoryDate":null,
                    "lastUpkeepDate":null,
                    "planUpkeepDate":"2018-01-26",
                    "lastInspectionDate":null,
                    "planInspectionDate":null
                }, {
                    "id":"1481185322811002",
                    "name":"呼吸机",
                    "sn":null,
                    "assetsNo":null,
                    "hospital":'浙江大学医学院附属第一医院',
                    "department":"急诊科",
                    "firstTypeName":"手术急救",
                    "modalName":"GALILEO",
                    "manufacturer":null,
                    "price":34900000,
                    "depreciationPrice":null,
                    "enableDate":null,
                    "usedTime":null,
                    "ageLimitMeasure":7.257534246575,
                    "scrapTime":null,
                    "repairTime":null,
                    "repairStatus":null,
                    "deviceStatus":null,
                    "haltMin":null,
                    "faultDescription":null,
                    "serviceProvider":"哈美顿",
                    "responsible":"gcs",
                    "warn":"Y",
                    "haveFaultMin":null,
                    "lastCompulsoryDate":null,
                    "planCompulsoryDate":null,
                    "lastUpkeepDate":null,
                    "planUpkeepDate":"2017-12-28",
                    "lastInspectionDate":null,
                    "planInspectionDate":null
                }, {
                    "id":"1481185324747002",
                    "name":"呼吸机",
                    "sn":null,
                    "assetsNo":null,
                    "hospital":'浙江大学医学院附属第一医院',
                    "department":"脑外科监护室",
                    "firstTypeName":"手术急救",
                    "modalName":"RAPHAEL silver",
                    "manufacturer":null,
                    "price":23000000,
                    "depreciationPrice":null,
                    "enableDate":null,
                    "usedTime":null,
                    "ageLimitMeasure":13.180821917808,
                    "scrapTime":null,
                    "repairTime":null,
                    "repairStatus":null,
                    "deviceStatus":null,
                    "haltMin":null,
                    "faultDescription":null,
                    "serviceProvider":"上海垚兴医疗科技有限公司",
                    "responsible":"gcs",
                    "warn":"G",
                    "haveFaultMin":null,
                    "lastCompulsoryDate":null,
                    "planCompulsoryDate":null,
                    "lastUpkeepDate":null,
                    "planUpkeepDate":"2017-12-27",
                    "lastInspectionDate":null,
                    "planInspectionDate":null
                }, {
                    "id":"1481185323384002",
                    "name":"呼吸机",
                    "sn":null,
                    "assetsNo":null,
                    "hospital":'浙江大学医学院附属邵逸夫医院',
                    "department":"二十五病区",
                    "firstTypeName":"手术急救",
                    "modalName":"RAPHAEL silver",
                    "manufacturer":null,
                    "price":19500000,
                    "depreciationPrice":null,
                    "enableDate":null,
                    "usedTime":null,
                    "ageLimitMeasure":7.506849315068,
                    "scrapTime":null,
                    "repairTime":null,
                    "repairStatus":null,
                    "deviceStatus":null,
                    "haltMin":null,
                    "faultDescription":null,
                    "serviceProvider":"上海垚兴医疗科技有限公司",
                    "responsible":"gcs",
                    "warn":"R",
                    "haveFaultMin":null,
                    "lastCompulsoryDate":null,
                    "planCompulsoryDate":null,
                    "lastUpkeepDate":null,
                    "planUpkeepDate":"2017-12-27",
                    "lastInspectionDate":null,
                    "planInspectionDate":null
                }]},
        timer: null,
        init: function () { // 初始化方法
            this.initVariable();
            this.initLayout();
            /* 初始化echarts */
            this.initChart();
            /* 绑定事件 */
            this.bindEvent();
            /* 查询数据 */
            this.getData();
            clearInterval(this.timer);
            this.timer = setInterval(function () {
                publicAjax('../largeScreen/initData', 'post', {}, function () {});
            }, 29 * 60 * 1000);
        },
        getData: function () {
            var _this = this;
            publicAjax('../largeScreen/initData', 'post', {}, function (data) {
                if (data.ret) {
                    _this.data = data.data;
                    /* 填充图表数据 */
                    _this.setDeviceChart();
                    _this.setFaultChart();
                    _this.setUpkeepChart();

                    _this.setYearChart();
                    _this.setMonthChart();
                    _this.setCompletionChart();

                    _this.setNewList();
                } else {
                    flavrShowByTime(data.msg, null, 'error', false);
                }
            });
            this.getWarningData(1501, function (data) {
                _this[1501].status = true;
                _this[1501].data = data.data || [];
                var str = '';
                if (_this[1501].data.length) {
                    for (var i = 0; i < _this[1501].data.length; i++) {
                        str += '<tr>' +
                            '<td class="no-cal"><i style="'+getIconStyle('hitch', 'Y')+'"></i>' + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1501].data[i].deviceName) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1501].data[i].deviceModel) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1501].data[i].hospitalName) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1501].data[i].department) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1501].data[i].faultDepictHospital) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1501].data[i].repairTime) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1501].data[i].repairPersonName) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1501].data[i].faultTime) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1501].data[i].repairNo) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1501].data[i].engineerName) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1501].data[i].repairStatusStr) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1501].data[i].sn) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1501].data[i].maintainerName) + '</td></tr>';
                    }
                } else {
                    str += '<tr><td colspan="14">暂无数据！</td></tr>';
                }
                var table = _this.main.find('#list-table2');
                table.find('tbody').html(str);
                calTableData('list-table2', true);
                _this.setWarningList();
            });
            this.getWarningData(1502, function (data) {
                _this[1502].status = true;
                _this[1502].data = data.data || [];
                var str = '';
                if (_this[1502].data.length) {
                    for (var i = 0; i < _this[1502].data.length; i++) {
                        str += '<tr>' +
                            '<td class="no-cal"><i style="'+getIconStyle('repair', 'R')+'"></i>' + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1502].data[i].deviceName) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1502].data[i].deviceModel) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1502].data[i].hospitalName) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1502].data[i].department) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1502].data[i].faultDepictHospital) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1502].data[i].repairTime) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1502].data[i].repairPersonName) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1502].data[i].faultTime) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1502].data[i].repairNo) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1502].data[i].engineerName) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1502].data[i].repairStatusStr) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1502].data[i].sn) + '</td>' +
                            '<td class="no-cal">' + fixStr(_this[1502].data[i].maintainerName) + '</td></tr>';
                    }
                } else {
                    str += '<tr><td colspan="14">暂无数据！</td></tr>';
                }
                var table = _this.main.find('#list-table1');
                table.find('tbody').html(str);
                calTableData('list-table1', true);

                _this.setWarningList();
            });
            /* 强检提醒 */
            var str3 = '';
            for (var i = 0; i < _this[1503].data.length; i++) {
                str3 += '<tr>' +
                    '<td class="no-cal"><i style="'+getIconStyle('force', _this[1503].data[i].warn)+'"></i>' + '</td>' +
                    '<td class="no-cal spanTitle">' + (_this[1503].data[i].name || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1503].data[i].department || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1503].data[i].firstTypeName || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1503].data[i].modalName || '') + '</td>' +
                    '<td class="avg-1 text-right">' + fix2(_this[1503].data[i].ageLimitMeasure) + '</td>' +
                    '<td class="no-cal">' + (_this[1503].data[i].responsible || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1503].data[i].lastCompulsoryDate || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1503].data[i].planCompulsoryDate || '') + '</td>' +
                    '</tr>';
            }
            var table = _this.main.find('#list-table3');
            table.find('tbody').html(str3);
            calTableData('list-table3', true);

            /* 召回提醒 */
            var str4 = '';
            for (var i = 0; i < _this[1504].data.length; i++) {
                str4 += '<tr>' +
                    '<td class="no-cal"><i style="'+getIconStyle('recall', _this[1504].data[i].warn)+'"></i>' + '</td>' +
                    '<td class="no-cal spanTitle">' + (_this[1504].data[i].name || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1504].data[i].department || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1504].data[i].firstTypeName || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1504].data[i].modalName || '') + '</td>' +
                    '<td class="avg-1 text-right">' + fix2(_this[1504].data[i].ageLimitMeasure) + '</td>' +
                    '<td class="no-cal">' + (_this[1504].data[i].scrq || '2016-01-20') + '</td>' +
                    '<td class="no-cal">' + (_this[1504].data[i].serviceProvider || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1504].data[i].responsible || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1504].data[i].faultDescription || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1504].data[i].scrapTime || '2018-02-01') + '</td>' +
                    '</tr>';
            }
            var table = _this.main.find('#list-table4');
            table.find('tbody').html(str4);
            calTableData('list-table4', true);

            /* 安装提醒 */
            var str5 = '';
            for (var i = 0; i < _this[1505].data.length; i++) {
                str5 += '<tr>' +
                    '<td class="no-cal"><i style="'+getIconStyle('monitor', _this[1505].data[i].warn)+'"></i>' + '</td>' +
                    '<td class="no-cal spanTitle" onclick="winOpen(\'/charts/overview/assets/page?deviceId='+_this[1505].data[i].id+'\')">' + (_this[1505].data[i].name || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1505].data[i].department || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1505].data[i].firstTypeName || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1505].data[i].modalName || '') + '</td>' +
                    '<td class="avg-1 text-right">' + fix2(_this[1505].data[i].ageLimitMeasure) + '</td>' +
                    '<td class="no-cal">' + (_this[1505].data[i].responsible || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1505].data[i].lastInspectionDate || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1505].data[i].planInspectionDate || '') + '</td>' +
                    '</tr>';
            }
            var table = _this.main.find('#list-table5');
            table.find('tbody').html(str5);
            calTableData('list-table5', true);

            /* 保养提醒 */
            var str6 = '';
            for (var i = 0; i < _this[1506].data.length; i++) {
                str6 += '<tr>' +
                    '<td class="no-cal"><i style="'+getIconStyle('upkeep', _this[1506].data[i].warn)+'"></i>' + '</td>' +
                    '<td class="no-cal spanTitle">' + (_this[1506].data[i].name || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1506].data[i].department || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1506].data[i].firstTypeName || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1506].data[i].modalName || '') + '</td>' +
                    '<td class="avg-1 text-right">' + fix2(_this[1506].data[i].ageLimitMeasure) + '</td>' +
                    '<td class="no-cal">' + (_this[1506].data[i].serviceProvider || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1506].data[i].responsible || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1506].data[i].lastUpkeepDate || '') + '</td>' +
                    '<td class="no-cal">' + (_this[1506].data[i].planUpkeepDate || '') + '</td>' +
                    '</tr>';
            }
            var table = _this.main.find('#list-table6');
            table.find('tbody').html(str6);
            calTableData('list-table6', true);
        },
        getWarningData: function (deviceStatus, fn) {
            publicAjax('../largeScreen/queryRepairByRepairStatus', 'post', {deviceStatus: deviceStatus}, function (data) {
                fn(data);
            });
        },
        initLayout: function (){    /* 布局设置-各元素高度设置 */
            $('.content').height($('.content-wrapper').height() - 30);
            /* 设置左上部分高度 */
            var chartFaultHeight = this.chartFault.width();   // 设定的 设备情况分析（左上部分）中图表高度
            this.chartFault.height(chartFaultHeight);  // 故障次数图表的高度=此图表宽度
            this.chartUpkeep.height(chartFaultHeight);  //保养图表的高度=故障次数图表的宽度

            var deviceCountPriceHeight = this.chartFault.parent().height(); // 设定的设备金额、设备数量和新增、保内设备父元素的高度
            this.chartDevice.height(deviceCountPriceHeight); // 新增保内设备图表高度
            this.main.find('#device-count-price').height(deviceCountPriceHeight); // 设备数量、金额父元素的高度

            /* 月份图表高度 */
            var monthHeight = this.month.eq(0).height();
            var monthWidth = this.month.eq(0).width() - 60;
            this.chartMonth.width(monthHeight > monthWidth ? monthWidth : monthHeight);
        },
        initChart: function () {
            this.echartsDevice = echarts.init(this.chartDevice[0]);
            this.echartsFault = echarts.init(this.chartFault[0]);
            this.echartsUpkeep = echarts.init(this.chartUpkeep[0]);

            this.echartsYear = echarts.init(this.chartYear[0]);
            this.chartMonth0 = echarts.init(this.chartMonth[0]);
            this.chartMonth1 = echarts.init(this.chartMonth[1]);
            this.chartMonth2 = echarts.init(this.chartMonth[2]);
            this.echartsCompletion = echarts.init(this.chartCompletion[0]);
        },
        setDeviceChart: function (){    /* 设置保内保外图表 */
            /* 设备数量和设备金额 */
            if (this.data.deviceCountAndPriceMap) {
                numAnimate({
                    el: this.main.find('#device-count'),
                    newNum: this.data.deviceCountAndPriceMap.totleCount,
                    unit: '台'
                });
                numAnimate({
                    el: this.main.find('#device-price'),
                    newNum: this.data.deviceCountAndPriceMap.totlePrice,
                    fixNum: 2,
                    unit: '万元'
                });
            }
            /* 新增、保内设备 */
            var outsideDeviceCount = 60;
            var insideDeviceCount = 60;
            if (this.data.insideOutsideDeviceCountList) {
                if (this.data.insideOutsideDeviceCountList[0].type === 1) {
                    insideDeviceCount = this.data.insideOutsideDeviceCountList[0].counts;
                    outsideDeviceCount = this.data.insideOutsideDeviceCountList[1].counts;
                } else {
                    insideDeviceCount = this.data.insideOutsideDeviceCountList[1].counts;
                    outsideDeviceCount = this.data.insideOutsideDeviceCountList[0].counts;
                }
                if (insideDeviceCount > outsideDeviceCount) {
                    insideDeviceCount = 100;
                    outsideDeviceCount = 60;
                } else if (insideDeviceCount < outsideDeviceCount) {
                    insideDeviceCount = 60;
                    outsideDeviceCount = 100;
                } else {
                    insideDeviceCount = 60;
                    outsideDeviceCount = 60;
                }
            }
            this.optionDevice.series[0].data[0] = outsideDeviceCount;
            this.optionDevice.series[0].data[1] = insideDeviceCount;
            this.echartsDevice.setOption(this.optionDevice);
        },
        setFaultChart: function () {
            var deviceCount = 0;
            var faultCount = 0;
            var faultRatio = 0;
            if (this.data.repairAndUpkeepDeviceCountMap) {
                numAnimate({
                    el: this.main.find('#fault-times'),
                    newNum: this.data.repairAndUpkeepDeviceCountMap.repairCount,
                    unit: '次'
                });
                deviceCount = this.data.repairAndUpkeepDeviceCountMap.deviceCount;
                faultCount = this.data.repairAndUpkeepDeviceCountMap.repairCount;
            }
            if (this.data.repairRatioMap) {
                faultRatio = this.data.repairRatioMap.reapirRatio;
                numAnimate({
                    el: this.main.find('#fault-ratio'),
                    newNum: faultRatio,
                    fixNum: 2,
                    unit: '‰'
                });
            }
            console.log(deviceCount, faultCount)
            this.optionFault.series[1].data[0].value = faultCount;
            this.optionFault.series[1].data[1].value = Math.abs(deviceCount - faultCount);
            this.optionFault.tooltip.formatter = '设备数量：' + deviceCount + '台</br>故障数量：' + faultCount + '台</br>故障率：' + faultRatio + '‰';
            this.optionFault.series[0].label.normal.formatter = '故障率\n\n' + faultRatio + '‰';
            this.echartsFault.setOption(this.optionFault);
        },
        setUpkeepChart: function () {
            var upkeepTotle = 0;
            if (this.data.upkeepDegreeDetailMap) {
                upkeepTotle = this.data.upkeepDegreeDetailMap.upkeepTotle;
                numAnimate({
                    el: this.main.find('#upkeep-month'),
                    newNum: this.data.upkeepDegreeDetailMap.sameMonth,
                    unit: '次'
                });
                numAnimate({
                    el: this.main.find('#upkeep-year'),
                    newNum: this.data.upkeepDegreeDetailMap.sameYear,
                    unit: '次'
                });
            }
            if (this.data.upkeepRatioMap) {
                numAnimate({
                    el: this.main.find('#upkeep-month-yoy'),
                    newNum: this.data.upkeepRatioMap.upkeepMonthRatio,
                    fixNum: 2,
                    unit: '%'
                });
                numAnimate({
                    el: this.main.find('#upkeep-year-yoy'),
                    newNum: this.data.upkeepRatioMap.upkeepYearRatio,
                    fixNum: 2,
                    unit: '%'
                });
            }
            this.optionUpkeep.tooltip.formatter = '保养次数：' + upkeepTotle + '次';
            this.optionUpkeep.series[0].label.normal.formatter = '保养次数\n\n' + upkeepTotle + '次';
            this.echartsUpkeep.setOption(this.optionUpkeep);
        },
        setMonthChart: function () {
            var completeInstallRatio = 0,
                completeUpkeepRatio = 0,
                completeRepairRatio = 0;
            if (this.data.repairUpkeepInstallByMonthMap) {
                completeInstallRatio = this.data.repairUpkeepInstallByMonthMap.completeInstallRatio;
                completeUpkeepRatio = this.data.repairUpkeepInstallByMonthMap.completeUpkeepRatio;
                completeRepairRatio = this.data.repairUpkeepInstallByMonthMap.completeRepairRatio;
                numAnimate({
                    el: this.month.eq(0).find('.value'),
                    newNum: completeInstallRatio,
                    fixNum: 2,
                    unit: '%'
                });
                numAnimate({
                    el: this.month.eq(1).find('.value'),
                    newNum: completeUpkeepRatio,
                    fixNum: 2,
                    unit: '%'
                });
                numAnimate({
                    el: this.month.eq(2).find('.value'),
                    newNum: completeRepairRatio,
                    fixNum: 2,
                    unit: '%'
                });
            }
            this.optionMonth.series[2].data[0].value = completeInstallRatio;
            this.optionMonth.series[2].data[1].value = 100- completeInstallRatio;
            this.chartMonth0.setOption(this.optionMonth);
            this.optionMonth.series[2].data[0].value = completeUpkeepRatio;
            this.optionMonth.series[2].data[1].value = 100- completeUpkeepRatio;
            this.chartMonth1.setOption(this.optionMonth);
            this.optionMonth.series[2].data[0].value = completeRepairRatio;
            this.optionMonth.series[2].data[1].value = 100- completeRepairRatio;
            this.chartMonth2.setOption(this.optionMonth);
        },
        setCompletionChart: function () {
            if (this.data.cityContractCompleteRatioList) {
                var list = this.data.cityContractCompleteRatioList;
                for (var i = 0; i < list.length; i++) {
                    this.optionCompletion.yAxis[0].data[i] = list[i].city;
                    this.optionCompletion.series[0].data[i].value = list[i].contractCompleteRatio;
                    this.optionCompletion.series[1].data[i].label = {
                        normal: {
                            show: true,
                            position: "inside",
                            textStyle: {
                                color: '#fff'
                            },
                            formatter: fix2(list[i].contractCompleteRatio) + '%'
                        }
                    };
                }
            }
            this.echartsCompletion.setOption(this.optionCompletion);
        },
        setYearChart: function () {
            var installTotel = 0,
                completeInstallTotel = 0,
                completeInstallRatio = '0.00',
                upkeepTotel = 0,
                completeRepairTotel = 0,
                completeRepairRatio = '0.00',
                repairTotel = 0,
                completeUpkeepTotel = 0,
                completeUpkeepRatio = '0.00';
            if (this.data.repairUpkeepInstallByYearMap) {
                installTotel = this.data.repairUpkeepInstallByYearMap.installTotel;
                completeInstallTotel = this.data.repairUpkeepInstallByYearMap.completeInstallTotel;
                completeInstallRatio = fix2(this.data.repairUpkeepInstallByYearMap.completeInstallRatio);
                upkeepTotel = this.data.repairUpkeepInstallByYearMap.upkeepTotel;
                completeRepairTotel = this.data.repairUpkeepInstallByYearMap.completeRepairTotel;
                completeRepairRatio = fix2(this.data.repairUpkeepInstallByYearMap.completeRepairRatio);
                repairTotel = this.data.repairUpkeepInstallByYearMap.repairTotel;
                completeUpkeepTotel = this.data.repairUpkeepInstallByYearMap.completeUpkeepTotel;
                completeUpkeepRatio = fix2(this.data.repairUpkeepInstallByYearMap.completeUpkeepRatio);
            }
            this.optionYear.series[0].data[0].value = completeInstallRatio;
            this.optionYear.series[0].data[1].value = 125 - completeInstallRatio;
            this.optionYear.series[1].data[0].value = completeUpkeepRatio;
            this.optionYear.series[1].data[1].value = 125 - completeUpkeepRatio;
            this.optionYear.series[2].data[0].value = completeRepairRatio;
            this.optionYear.series[2].data[1].value = 125 - completeRepairRatio;
            this.optionYear.tooltip.formatter = function (param) {
                if (param.dataIndex === 0) {
                    if (param.seriesIndex === 0) {
                        return "安装总数：" + installTotel + "<br/>" +
                            "安装完成数：" + completeInstallTotel + "<br/>" +
                            "安装完成率: " + completeInstallRatio + "%";
                    } else if (param.seriesIndex === 1) {
                        return "保养总数：" + upkeepTotel + '<br/>' +
                            "保养完成数：" + completeUpkeepTotel + "<br/>" +
                            "保养完成率: " + completeUpkeepRatio + "%";
                    } else if (param.seriesIndex === 2) {
                        return "维修总数：" + repairTotel + "<br/>" +
                            "维修完成数：" + completeRepairTotel + "<br/>" +
                            "维修完成率: " + completeRepairRatio + "%";
                    }
                }
            };
            var width = this.chartYear.width();
            var height = this.chartYear.height();
            if (width < height) {
                this.optionYear.legend.bottom = (height - width) / 2 + 'px';
            }
            this.echartsYear.setOption(this.optionYear);
        },
        setWarningList: function () {
            var _this = this;
            var warningList = this.main.find('.warning-list');
            warningList.css('flex', 1);
            var showLength = parseInt((warningList.height()) / 40);
            warningList.height(showLength * 40);
            warningList.css('flex', 'none');
            var otherList = warningList.find('.other-list');
            if (this[1501].status && this[1502].status) {
                var num = 1501;
                this.main.find('.warning-icon .tip').each(function (index) {
                    numAnimate({
                        el: $(this),
                        newNum: _this[num===1501?1502:(num===1502?1501:num)].data.length,
                        fixNum: 0,
                        unit: ''
                    });
                    num++;
                });

                var str1 = '';
                for (var i = 0;i < this[1502].data.length; i++) {
                    if (this[1502].data[i].repairStatusStr === '待处理') {
                        str1 += '<li>' +
                            '<i style="'+getIconStyle('repair', this[1502].data[i].warn)+'"></i>' +
                            '<span show-title>' +
                            fixStr(this[1502].data[i].hospitalName) + fixStr(this[1502].data[i].repairPersonName) +
                            '对' + fixStr(this[1502].data[i].deviceName) + '进行保修，请及时处理。' +
                            '</span>' +
                            '</li>';
                    } else if (this[1502].data[i].repairStatusStr === '待指派') {
                        str1 += '<li>' +
                            '<i style="'+getIconStyle('repair', this[1502].data[i].warn)+'"></i>' +
                            '<span show-title>' +
                                fixStr(this[1502].data[i].hospitalName) + fixStr(this[1502].data[i].deviceName) + '的报修，已安排' +
                                fixStr(this[1502].data[i].maintainerName) + '进行处理。' +
                            '</span>' +
                            '</li>';
                    } else if (this[1502].data[i].repairStatusStr === '待维修') {
                        str1 += '<li>' +
                            '<i style="'+getIconStyle('repair', this[1502].data[i].warn)+'"></i>' +
                            '<span show-title>' +
                            fixStr(this[1502].data[i].hospitalName) + fixStr(this[1502].data[i].deviceName) + '的报修，已安排' +
                            fixStr(this[1502].data[i].maintainerName) + fixStr(this[1502].data[i].engineerName) + '前去维修。' +
                            '</span>' +
                            '</li>';
                    } else if (this[1502].data[i].repairStatusStr === '待确认') {
                        str1 += '<li>' +
                            '<i style="'+getIconStyle('repair', this[1502].data[i].warn)+'"></i>' +
                            '<span show-title>' +
                            fixStr(this[1502].data[i].hospitalName) + fixStr(this[1502].data[i].deviceName) +
                            fixStr(this[1502].data[i].maintainerName) + fixStr(this[1502].data[i].engineerName) + '已维修完毕。' +
                            '</span>' +
                            '</li>';
                    } else {
                        str1 += '<li>' +
                            '<i style="'+getIconStyle('repair', this[1502].data[i].warn)+'"></i>' +
                            '<span show-title>' +
                            fixStr(this[1502].data[i].hospitalName) + fixStr(this[1502].data[i].deviceName) +
                            this[1502].data[i].repairStatusStr +
                            '</span>' +
                            '</li>';
                    }
                }

                var str2 = '';
                for (var i = 0;i < this[1501].data.length; i++) {
                    if (this[1501].data[i].repairStatusStr === '待处理') {
                        str2 += '<li>' +
                            '<i style="'+getIconStyle('hitch', this[1501].data[i].warn)+'"></i>' +
                            '<span show-title>' +
                            fixStr(this[1501].data[i].hospitalName) + fixStr(this[1501].data[i].repairPersonName) +
                            '对' + fixStr(this[1501].data[i].deviceName) + '进行保修，请及时处理。' +
                            '</span>' +
                            '</li>';
                    } else if (this[1501].data[i].repairStatusStr === '待指派') {
                        str2 += '<li>' +
                            '<i style="'+getIconStyle('hitch', this[1501].data[i].warn)+'"></i>' +
                            '<span show-title>' +
                            fixStr(this[1501].data[i].hospitalName) + fixStr(this[1501].data[i].deviceName) + '的报修，已安排' +
                            fixStr(this[1501].data[i].maintainerName) + '进行处理。' +
                            '</span>' +
                            '</li>';
                    } else if (this[1501].data[i].repairStatusStr === '待维修') {
                        str2 += '<li>' +
                            '<i style="'+getIconStyle('hitch', this[1501].data[i].warn)+'"></i>' +
                            '<span show-title>' +
                            fixStr(this[1501].data[i].hospitalName) + fixStr(this[1501].data[i].deviceName) + '的报修，已安排' +
                            fixStr(this[1501].data[i].maintainerName) + fixStr(this[1501].data[i].engineerName) + '前去维修。' +
                            '</span>' +
                            '</li>';
                    } else if (this[1501].data[i].repairStatusStr === '待确认') {
                        str2 += '<li>' +
                            '<i style="'+getIconStyle('hitch', this[1501].data[i].warn)+'"></i>' +
                            '<span show-title>' +
                            fixStr(this[1501].data[i].hospitalName) + fixStr(this[1501].data[i].deviceName) +
                            fixStr(this[1501].data[i].maintainerName) + fixStr(this[1501].data[i].engineerName) + '已维修完毕。' +
                            '</span>' +
                            '</li>';
                    }
                }
                otherList.html(str2);

                var str3 = '';
                for (var i = 0;i < this[1503].data.length; i++) {
                    str3 += '<li>' +
                        '<i style="'+getIconStyle('force', this[1503].data[i].warn)+'"></i>' +
                        '<span show-title>' + fixStr(this[1503].data[i].hospital) +
                        (this[1503].data[i].name || '') + '在' + (this[1503].data[i].planCompulsoryDate || '') + '需强检。' +
                        '</span>' +
                        '</li>';
                }
                otherList.append(str3);

                var str4 = '';
                for (var i = 0;i < this[1504].data.length; i++) {
                    str4 += '<li>' +
                        '<i style="'+getIconStyle('recall', this[1504].data[i].warn)+'"></i>' +
                        '<span show-title>' + fixStr(this[1504].data[i].hospital) +
                        (this[1504].data[i].name || '') + '在' + (this[1504].data[i].scrapTime || '') + '被召回。' +
                        '</span>' +
                        '</li>';
                }
                otherList.append(str4);

                var str5 = '';
                for (var i = 0;i < this[1505].data.length; i++) {
                    str5 += '<li>' +
                        '<i style="'+getIconStyle('monitor', this[1505].data[i].warn)+'"></i>' +
                        '<span show-title>' + fixStr(this[1505].data[i].hospital) +
                        (this[1505].data[i].name || '') + '在' + (this[1505].data[i].planInspectionDate || '') + '需巡检。' +
                        '</span>' +
                        '</li>';
                }
                otherList.append(str5);

                var str6 = '';
                for (var i = 0;i < this[1506].data.length; i++) {
                    str6 += '<li>' +
                        '<i style="'+getIconStyle('upkeep', this[1506].data[i].warn)+'"></i>' +
                        '<span show-title>' + fixStr(this[1506].data[i].hospital) +
                        (this[1506].data[i].name || '') + '在' + (this[1506].data[i].planUpkeepDate || '') + '需保养。' +
                        '</span>' +
                        '</li>';
                }
                otherList.append(str6);

                /* 设置滚动 */
                var length = (function () {
                    if (_this[1502].data.length > 2) {
                        var length = _this[1501].data.length + _this[1503].data.length + _this[1504].data.length + _this[1505].data.length + _this[1506].data.length;
                        if (length > (showLength - 2)) {
                            return 2;
                        } else {
                            return showLength - length > _this[1502].data.length ? showLength - length : _this[1502].data.length;
                        }
                    } else {
                        return _this[1502].data.length;
                    }
                })();
                warningList.find('.repair-list').html(str1);
                showTitle(warningList);
                warningList.find('.repair-list').parent().vTicker({
                    showItems: length
                });
                otherList.parent().vTicker({
                    showItems: showLength - length
                });
            }
        },
        setNewList: function () {
            var eventList = this.main.find('.event-list');
            showTitle(eventList);
            eventList.vTicker({
                showItems: parseInt(eventList.height() / eventList.find('li').eq(0).height())
            });
        },
        bindEvent: function () {
            var _this = this;
            this.main.find('#fullscreen').off().click(function () {
                _this.fullscreen($(this));
            });

            /* 监听全屏 */
            function initLayout0() {
                if(!document.fullscreen) {
                    $('.content').height(document.documentElement.clientHeight - 131);
                }
                _this.init();
            }
            function initLayout1() {
                if(!document.mozFullScreen) {
                    $('.content').height(document.documentElement.clientHeight - 131);
                }
                _this.init();
            }
            function initLayout2() {
                if(!document.webkitIsFullScreen) {
                    $('.content').height(document.documentElement.clientHeight - 131);
                }
                _this.init();
            }
            function initLayout3() {
                if(!document.msFullscreenElement) {
                    $('.content').height(document.documentElement.clientHeight - 131);
                }
                _this.init();
            }
            document.removeEventListener('fullscreenchange', initLayout0);
            document.addEventListener('fullscreenchange', initLayout0, false);

            document.removeEventListener('mozfullscreenchange', initLayout1);
            document.addEventListener('mozfullscreenchange', initLayout1, false);

            document.removeEventListener('webkitfullscreenchange', initLayout2);
            document.addEventListener('webkitfullscreenchange', initLayout2, false);

            document.removeEventListener('msfullscreenchange', initLayout3);
            document.addEventListener('msfullscreenchange', initLayout3, false);

            /* 提醒事件列表 */
            var iconFrame = this.main.find('.icon-frame');
            var listModel = this.main.find('#list-model');
            var listTable = listModel.find('.list-table');
            iconFrame.off().click(function (){
                var index = $(this).index('.icon-frame');
                if($(this).hasClass('active')) {
                    $(this).removeClass('active');
                    listModel.hide();
                    listTable.hide();
                } else {
                    iconFrame.removeClass('active');
                    $(this).addClass('active');
                    listModel.show();
                    listTable.hide();
                    listTable.eq(index).show();
                }
            });
            /* 提醒事件详情模态框关闭 */
            this.main.find('#list-close').off().click(function () {
                iconFrame.removeClass('active');
                listModel.hide();
                listTable.hide();
            });
        },
        fullscreen: function (el) {
            if (this.main.hasClass('fullscreen')) {
                /* 取消全屏 */
                el.removeClass('fa-compress');
                el.addClass('fa-arrows-alt');
                this.main.removeClass('fullscreen');
                exitFullscreen();
            } else {
                /* 执行全屏 */
                el.removeClass('fa-arrows-alt');
                el.addClass('fa-compress');
                this.main.addClass('fullscreen');
                fullscreen();
            }
        }
    };

    overview.init();
    window.addEventListener("load", init, false);
});

var echo_websocket;
var wsUri = "ws://localhost:" + location.port + location.pathname.substring(0, location.pathname.substr(1).indexOf('/') + 1) + "/websocket.do";

window.messageObjArr = [];
function createWebsocket() {
    echo_websocket = new WebSocket(wsUri);

    echo_websocket.onopen = function (evt) {
        writeToScreen("Connected !");
        //doSend(textID.value);
    };
    echo_websocket.onmessage = function (evt) {
        writeToScreen("Received message: " + evt.data);
        var data = JSON.parse(evt.data);
        var list = null,
            item = null,
            exigencyRepair = $('#exigencyRepair'),  /* 紧急维修提示 */
            highRiskRepair = $('#highRiskRepair'),
            planUpkeep = $('#planUpkeep'),
            warningList = $('.warning-list'),  /* 警示列表滚动框 */
            showLength = parseInt((warningList.height()) / 40), /* 警示列表滚动框显示的条目数 */
            repairList = $('.repair-list'),
            otherList = $('.other-list');
        if (data.type == 0) { //无设备报修
            /* 处理弹窗 */
            messageObjArr.push(data);
            dealPushMessage();
        } else if (data.type == 1) {
            /* 处理弹窗 */
            messageObjArr.push(data);
            dealPushMessage();

            /* 列表闪动 */
            list = repairList;
            item = $('<li class="blink"><i style="'+getIconStyle('repair')+'"></i><span show-title>' + data.message + '</span></li>');
            list.parent().vTicker('stop');
            showTitle(item);
            list.prepend(item);
            numAnimate({
                el: exigencyRepair,
                newNum: parseInt(exigencyRepair.text()) + 1,
                fixNum: 0,
                unit: ''
            });
            var otherLength = otherList.find('li').length;
            warningList.height(showLength * 40);
            var length = list.find('li').length;
            list.parent().vTicker('stop');
            setTimeout(function () {
                item.removeClass('blink');
                list.parent().vTicker({
                    showItems: (function () {
                        if (length > 2) {
                            if (otherLength > (showLength - 2)) {
                                return 2;
                            } else {
                                return showLength - otherLength > length ? showLength - otherLength : length;
                            }
                        } else {
                            return length;
                        }
                    })()
                });
            }, 30 * 1000);
        } else if (data.type == 2 || data.type == 3) {
            /* 处理弹窗 */
            if (data.type == 2) {
                messageObjArr.push(data);
                dealPushMessage();
            }

            /* 列表闪动 */
            list = otherList;
            item = $('<li class="blink">' +
                '<i style="'+getIconStyle(data.type == 2 ? 'hitch' : 'upkeep')+'"></i>' +
                '<span show-title>' + data.message + '</span>' +
                '</li>');
            list.parent().vTicker('stop');
            showTitle(item);
            list.prepend(item);
            numAnimate({
                el: data.type == 2 ? highRiskRepair : planUpkeep,
                newNum: parseInt((data.type == 2 ? highRiskRepair : planUpkeep).text()) + 1,
                fixNum: 0,
                unit: ''
            });
            setTimeout(function () {
                item.removeClass('blink');
                list.parent().vTicker({
                    showItems: showLength - parseInt(repairList.height() / 40)
                });
            }, 30 * 1000);
        }
    };
    echo_websocket.onerror = function (evt) {
        writeToScreen('<span style="color: red;">ERROR:</span> '
            + evt.data);
        echo_websocket.close();
    };
    echo_websocket.onclose = function () {
        writeToScreen('<span style="color: red;">CLOSE:</span> ');
        /*setTimeout(function () {
            init();
        }, 5000);*/
    };

    clearScreen();
}

window.dealPushMessage = function () {
    setTimeout(function () {
        $('.progress').html(messageObjArr.index + 1 + '/' + messageObjArr.length + '条');
        if ($('.score-797987978').is(':visible')) return;
        messageObjArr.index = (typeof messageObjArr.index === 'number' ? messageObjArr.index : -1) + 1;
        if (messageObjArr.index >= messageObjArr.length) return;
        var messageObj = messageObjArr[messageObjArr.index];
        $('.progress').html(messageObjArr.index + 1 + '/' + messageObjArr.length + '条');
        $.eventAlert(messageObj);
    }, 1200);
}


function init() {
    output = document.getElementById("output");
    writeToScreen("Connecting to " + wsUri);

    createWebsocket();
}

function send_echo() {
    if(echo_websocket!=null && echo_websocket.readyState==1)
    {
        doSend(textID.value);
    } else
    {
        createWebsocket();
        //重新连接后，跟着马上发送数据会失败！（我猜测是异步执行的关系）
        //得等到  连接成功事件收到后 再发送。
    }
}
function closeWebSocket() {
    echo_websocket.close();
}
function doSend(message) {
    echo_websocket.send(message);
    writeToScreen("Sent message: " + message);
}
function writeToScreen(message) {
    console.log(message);
}
function clearScreen(message) {
}

function fix2(str) {
    return parseFloat(str || 0).toFixed(2);
}
function fixStr(string) {
    return string || '';
}

function getIconStyle(code, warn) {
    return 'background-image:url(../images/overview/' + code + (warn ? '-' + warn : '') + '.png)'
}

// 全屏
function fullscreen() {
    var docElm = document.documentElement;
    if (docElm.requestFullscreen) {
        docElm.requestFullscreen();
    } else if (docElm.mozRequestFullScreen) {
        docElm.mozRequestFullScreen();
    } else if (docElm.webkitRequestFullScreen) {
        docElm.webkitRequestFullScreen();
    } else if (docElm.msRequestFullscreen) {
        docElm.msRequestFullscreen();
    }
}

// 退出全屏
function exitFullscreen() {
    if (document.exitFullscreen) {
        document.exitFullscreen();
    } else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
    } else if (document.webkitCancelFullScreen) {
        document.webkitCancelFullScreen();
    } else if (document.msExitFullscreen) {
        document.msExitFullscreen();
    }
}

/* 列表总计 */
function calTableData(tableId) {
    var lang = 'zh';
    var isType = false;
    var thHasVal = false;
    var param = {};
    if (typeof tableId === 'object') {
        isType = tableId.isType;
        param = tableId.param || {};
        tableId = tableId.tableId;
    }
    var table = $("#" + tableId);
    var ths = table.find('thead th').each(function(){
        var obj = $(this);
        if (obj.attr('value')) {
            thHasVal = true;
            return;
        }
    });
    if (thHasVal) {
        var str = '';
        for (var i = 0; i < ths.length; i++) {
            str += '<td class="' + ths.eq(i).attr('class') + '">' + (ths.eq(i).attr('value') || '') + '</td>'
        }

        if (table.find('tfoot').length) {
            table.find('tfoot').html("<tr>" + str + "</tr>");
        } else {
            table.append("<tfoot><tr>" + str + "</tr></tfoot>");
        }
    } else {
        var countClassArr = [];//用来存放要计算列的类名
        var amountArr = [];
        $("#" + tableId + " tbody tr:first td").each(function () {
            if ($(this)[0].className.indexOf("no-cal") === -1) {//如果该列含有no-cal则表示不需要计算
                var totalNum = $(this)[0].className.split(" ")[0];//获取要计算的列的class name
                countClassArr.push(totalNum);
            } else {
                countClassArr.push('no-cal');
            }
        });
        for (var x = 2; x < countClassArr.length; x++) {
            var num = 0;
            if (countClassArr[x] != 'no-cal') {
                $("#" + tableId + " ." + countClassArr[x]).each(function () {
                    num = num + parseFloat($(this)[0].innerText);
                });
            }

            if (countClassArr[x].indexOf("total") != -1) {//如果是带有total的类名则算总值
                amountArr.push(num);
            } else if (countClassArr[x].indexOf("no-cal") != -1) {
                amountArr.push(null);
            } else {//否则计算平均值
                amountArr.push(num / $("#" + tableId + " ." + countClassArr[x]).length);
            }
        }
        appendStr = '';
        for (var x = 0; x < amountArr.length; x++) {
            appendStr += "<td class='text-right'>" + (amountArr[x] == null ? '' : parseFloat(amountArr[x]).toFixed(2)) + "</td>"
        }
        if (table.find('tfoot').length) {
            table.find('tfoot').html("<tr><td class='text-center'>" + (lang === 'en' ? 'Total' : '总计') + "</td><td>"+table.find('tbody tr').length+"</td>" + appendStr + "</tr>");
        } else {
            table.append("<tfoot><tr><td class='text-center'>" + (lang === 'en' ? 'Total' : '总计') + "</td><td>"+table.find('tbody tr').length+"</td>" + appendStr + "</tr></tfoot>");
        }
    }

    if (table.find('tr').length > 600) {
        table.tableHeadFixer({'head': true, 'foot': true});
    } else {
        table.tableHeadFixer({'left': 2, 'head': true, 'foot': true});
    }
}

function showTitle(el) {
    var element = null;
    if (el) {
        element = el.find('[show-title]');
    } else {
        element = $('[show-title]');
    }
    element.each(function(){
        $(this).attr('title', $(this).text());
    });
}
/* 跳转维修详情 */
function queryRepairInfo(id){
    window.open($('#apiUrl').val()+"/repair/info?id="+id);
}

